﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTO_HealthInsurance;
using BLL_HealthInsurance;
using DAO_HealthInsurance;
namespace HealthInsuranceMgm.Admin
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void btnlogin_Click(object sender, EventArgs e)
        {

            DAOSecurityPassword seccu = new DAOSecurityPassword();
            string username = txtusername.Text;
            string password = txtpassword.Text;
            DTOAdminLogin objAdmin = new DTOAdminLogin();
            BLLAdmin objBll = new BLLAdmin();
           
           
           if(username!=""&& password!=""){
               objAdmin.UserName = username;
               objAdmin.Password =seccu.EnCrypt( password).ToString();
             if (objBll.DAOAdminLogin(objAdmin) == true)
            {   
                Session["username"] = txtusername.Text;
                Session["password"] = txtpassword.Text;
                Session.Timeout = 10000;
                Response.Redirect("AdminFunction.aspx");

            }
            else { 
                lblthongbao.Text="UserName Or Password not Match!";
                Response.Write(objAdmin.Password);
            }
           }else{
               lblthongbao.Text = "Sorry! Username or Password not Empty!";
           }
        }
    }
}